package com.bdf.ipharma.gui;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;

import javax.swing.JPanel;

import oracle.jdeveloper.layout.GridBagConstraints2;

import org.apache.log4j.Logger;

import com.bdf.ipharma.starter.McdError;
import com.bdf.ipharma.starter.McdMain;

public class GUIExtraccionReposicion extends GUIWindow{

	static final Logger logger = Logger.getLogger(GUIPopUpProdRepo.class);
	
	private McdMain mcdMain;
	
	public GUIExtraccionReposicion(McdMain pMain) {
		super(pMain);
	      try {
	    	  this.mcdMain = pMain;
	    	  jbInit();
	      } catch (Exception e) {
	    	  logger.fatal("GUIExtraccionReposicion + "+ e.getMessage());
	         McdError.add(e);
	      }
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
		/**
		 * Vistas
		 */
	
		GUIExtraccionProd guiExtraccionProd;
		GUIReposicionProd guiReposicionProd;
		
	
	   /**
	    * The Layouts.
	    */

	   GridBagLayout layoutImage = new GridBagLayout();
	   GridBagLayout layoutButtons = new GridBagLayout();

	   BorderLayout layoutMenu = new BorderLayout();

	   CardLayout layoutBase = new CardLayout();
	   
	   /**
	    * The main panel.
	    */
	   JPanel jPanelBase = new JPanel();

	   JPanel jPanelButtons = new JPanel();
	 
	   JPanel jPanelImage = new JPanel();

	   /**
	    * 
	    */
	   GUIButtonImage jButtExtraccion;

	   GUIButtonImage jButtReposicion;
	   
	   GUIButtonImage jButtonExit;
	   
	   
		   /**
	    * Initializes the state of this instance.
	    */
	   private void jbInit() throws Exception {

	      this.setLayout(layoutMenu);
	      this.setBackground(Colors.MNU_BACK);
	      this.setRequestFocusEnabled(false);
	      
	      jButtonExit = new GUIButtonImage(Images.buttExit, Images.buttExitDn);
	      
	      jButtExtraccion = new GUIButtonImage(Texts.BTN_EXTRACCION, Images.buttOk,
	              Images.buttOkDn);
	      jButtExtraccion.addActionListener(new GUIExtraccionReposicion_jButtExtraccion_actionAdapter(this));
	      
	      jButtReposicion = new GUIButtonImage(Texts.BTN_REPOSICION, Images.buttOk,
	              Images.buttOkDn);
	      
	      jButtReposicion.addActionListener(new GUIExtraccionReposicion_jButtReposicion_actionAdapter(this));
	      
	      
	      
	      jPanelBase.add(jButtExtraccion, new GridBagConstraints2(0, 0, 1, 1, 1.0, 0.0,
	    		  GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4,
	                      4, 0, 0), 0, 0));
	      
	      jPanelBase.add(jButtReposicion, new GridBagConstraints2(0, 1, 1, 1, 1.0, 0.0,
	    		  GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4,
	                      4, 0, 0), 0, 0));
	      
	      this.add(jPanelImage);
	        this.add(jPanelBase);
	      
	      
	      
	   }
	   
	   public void menu(String action) {

		      try {
		    	  if(action.equalsIgnoreCase("EXTRACCION")){
		    		  guiExtraccionProd = new GUIExtraccionProd(this.mcdMain);
			          this.mcdMain.setWindow(guiExtraccionProd);  
		    	  }
		    	  else{
		    		  guiReposicionProd= new GUIReposicionProd(this.mcdMain);
			          this.mcdMain.setWindow(guiReposicionProd);
		    	  }
		    		  
		          
		      } catch (Exception e) {
		         McdError.add(e);
		      }
		   }
	   
	   
	   public void jButtExtraccion_actionPerformed(ActionEvent e) {
		   this.menu("EXTRACCION");
	   }
	   
	   public void jButtReposicion_actionPerformed(ActionEvent e) {
		   this.menu("REPOSICION");
	   }
  

}

class GUIExtraccionReposicion_jButtExtraccion_actionAdapter implements java.awt.event.ActionListener {

	   GUIExtraccionReposicion adaptee;

	   GUIExtraccionReposicion_jButtExtraccion_actionAdapter (GUIExtraccionReposicion adaptee) {

	      this.adaptee = adaptee;
	   }

	   
	   public void actionPerformed(ActionEvent e) {

	      adaptee.jButtExtraccion_actionPerformed(e);
	   }
}

class GUIExtraccionReposicion_jButtReposicion_actionAdapter implements java.awt.event.ActionListener {

	   GUIExtraccionReposicion adaptee;

	   GUIExtraccionReposicion_jButtReposicion_actionAdapter (GUIExtraccionReposicion adaptee) {

	      this.adaptee = adaptee;
	   }

	   
	   public void actionPerformed(ActionEvent e) {

	      adaptee.jButtReposicion_actionPerformed(e);
	   }
}
